package com.ruoyi.flowable.listener;

import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @author 尹亮亮
 * @since 2024/6/4
 */

@Component
public class AutoApprovalTaskListener implements ExecutionListener {

    @Autowired
    private TaskService taskService; // 注入TaskService，用于操作任务


    @Override
    public void notify(DelegateExecution delegateExecution) {
        System.out.println("自动审批");
        delegateExecution.setVariable("autoApprove", "true");
        taskService.complete(delegateExecution.getId());
    }
}
